<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>layuiAdmin 网站用户</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiAdmin/dist/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiAdmin/dist/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="/Font-Awesome-master/css/font-awesome.min.css">
    <script src="/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
    <script src="/js/jquery-2.1.1.min.js"></script>
    <style>
        #mc {
            height: 100vh;
            width: 100vw;
            overflow: hidden;
            position: fixed;
            background: rgba(0, 0, 0, 0.5);
            z-index: 999999;
            display: none;
            align-items: center;
            justify-content: center;
        }

        .icon {
            width: 28px;
            height: 28px;
            line-height: 28px;
            border: 1px solid #e6e6e6;
            border-top-color: rgb(230, 230, 230);
            border-right-color: rgb(230, 230, 230);
            border-bottom-color: rgb(230, 230, 230);
            border-left-color: rgb(230, 230, 230);
            text-align: center;
            border-radius: 1px;
            -webkit-transition: all .4s ease;
            transition: all .4s ease;
            float: left;
            list-style: none;
        }

        .layui-table-body {
            z-index: 0;
        }
         .layui-btn .layui-icon{
            position: unset;
            vertical-align: middle;
        }
    </style>
</head>

<body>
    <div id="mc">
        <img style="max-height: 90%;max-width: 90%;" src="" alt="">
    </div>
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                <div class="layui-form-item">
                    {block name="check_input_id"}
                    {/block}
                    {block name="check_input"}
                    <div class="layui-inline">
                        <!-- <label class="layui-form-label">订单号</label> -->
                        <div class="layui-input-block">
                            <input type="text" name="order_no" placeholder="请输入订单号" autocomplete="off"
                                class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <!-- <label class="layui-form-label">时间范围</label> -->
                        <div class="layui-input-inline">
                            <input type="text" name="time_time" class="layui-input" id="time_time"
                                placeholder="请选择时间范围">
                        </div>
                    </div>
                    {if isset($ps) && $ps == 1}
                    <div class="layui-inline">
                        <!-- <label class="layui-form-label">状态</label> -->
                        <div class="layui-input-block">
                            <select name="status" lay-filter="type">
                                <option value="2" selected>待发货</option>
                            </select>
                        </div>
                    </div>
                    {elseif isset($ps) && $ps == 2}
                    <div class="layui-inline">
                        <!-- <label class="layui-form-label">状态</label> -->
                        <div class="layui-input-block">
                            <select name="status" lay-filter="type">
                                <option value="4" selected>待结算</option>
                            </select>
                        </div>
                    </div>
                    {elseif isset($status) && $status == 4}
                    <div class="layui-inline">
                        <!-- <label class="layui-form-label">状态</label> -->
                        <div class="layui-input-block">
                            <select name="status" lay-filter="type">
                                <option value="4" selected>待结算</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                         <!--<label class="layui-form-label">收货人</label> -->
                        <div class="layui-input-block">
                            <input type="text" name="sh_name" placeholder="请输入收货人" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    {else}
                    <div class="layui-inline">
                        <!-- <label class="layui-form-label">状态</label> -->
                        <div class="layui-input-block">
                            <select name="status" lay-filter="type">
                                <option value="">请选择状态</option>
                                <option value="1">待付款</option>
                                <option value="2">待发货</option>
                                <option value="3">待收货</option>
                                <option value="4">待结算</option>
                                <option value="5">结算申请中</option>
                                <option value="6">已完成</option>
                                <option value="7">取消</option>
                            </select>
                        </div>
                    </div>
                    {/if}
                    <div class="layui-inline">
                        <!-- <label class="layui-form-label">所属乡镇</label> -->
                        <div class="layui-input-block">
                            <select name="z_id" lay-filter="type">
                                {if isset($tow)}
                                <option value="">请选择所属乡镇</option>
                                {foreach $tow as $k=>$v}
                                <option value="{$v.id}">{$v.name}</option>
                                {/foreach}
                                {else}
                                {if isset($city) && isset($user)}
                                {foreach $city as $v}
                                {if $v.id == $user.township_id}
                                <option value="{$v.id}" selected>{$v.name}</option>
                                {/if}
                                {/foreach}
                                {elseif isset($city)}
                                <option value="">请选择所属乡镇</option>
                                {foreach $city as $v}
                                <option value="{$v.id}">{$v.name}</option>
                                {/foreach}
                                {/if}
                                {/if}
                            </select>
                        </div>
                    </div>
                    {/block}
                    {block name="check_input_ss"}
                    <div class="layui-inline">
                        <button class="layui-btn layui-bg-blue layui-btn-radius layuiadmin-btn-useradmin" lay-submit
                            lay-filter="LAY-user-front-search">
                            <i class="layui-icon">&#xe615;</i> 
                            筛选
                        </button>
                    </div>
                    {/block}
                </div>
            </div>
            <div class="layui-card-body">
                <div class="layui-btn-group" style="padding-bottom: 10px;">
                </div>
                <table id="demo" lay-filter="test"></table>
            </div>
        </div>
    </div>
    <script type="text/html" id="list_setting">
    <div class="layui-btn-group">
        {block name="setting_botton"}
        <button type="button" onclick="data_upload({{d.id}})" class="layui-btn layui-btn-sm">详情
        </button>
        {/block}
    </div>
</script>
    <!--系统图标-->
    <script type="text/html" id="list_icon">
    {{#if (d.icon){ }}
    <div class="icon"><i class="{{d.icon}}"></i></div>
    {{#} }}
</script>
    <!--常规图片-->
    <script type="text/html" id="list_image">
    <img src="{{d.image}}" onclick="fdtop('{{d.image}}')" alt="">
</script>
    {block name="js"}
    {/block}
    <!-- 配置文件 -->
    <script type="text/javascript" src="/plug/UEditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="/plug/UEditor/ueditor.all.js"></script>
    <script>
        function data_delete(id) {
            //删除按钮操作
            layui.use('layer', function () {
                var $ = layui.$
                    , table = layui.table
                    , layer = layui.layer
                layer.confirm('确定删除吗？', function (index) {

                    //执行 Ajax 后重载
                    $.ajax({
                        'url': "{:url('delete')}",
                        'method': 'POST',
                        'data': { id: id },
                        'success': function (res) {
                            if (res.code == 200) {
                                layer.msg('删除成功', {
                                    time: 1500 //2秒关闭（如果不配置，默认是3秒）
                                }, function () {
                                    table.reload('demo');
                                });
                            } else {
                                layer.msg(res.message);
                            }
                        }
                    })
                });
            })

        }
        function data_upload(id) {
            //编辑按钮操作
            layui.use('layer', function () {
                var $ = layui.$
                    , table = layui.table
                    , layer = layui.layer;
                layer.open({
                    type: 2
                    , title: '查看'
                    , content: '/admin/order/upload.html' + '?id=' + id
                    , maxmin: true
                    , area: ["{$popup_size.width}", "{$popup_size.height}"]
                    , btn: ['删除', '编辑', '取消']
                    , yes: function (index, layero) {
                        "{if $login['id'] !== 1}"
                        layer.msg('没有删除权限');
                        return false;
                        "{/if}"
                        var iframeWindow = window['layui-layer-iframe' + index]
                        var submitID = 'LAY-user-front-submit'
                        var submit = layero.find('iframe').contents().find('#' + submitID);
                        //监听提交
                        iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
                            var field = data.field; //获取提交的字段
                            // 提交 Ajax 成功后，静态更新表格中的数据
                            $.ajax({
                                'url': "{:url('delete')}",
                                'method': 'POST',
                                'data': { id: id },
                                'success': function (res) {
                                    if (res.code == 200) {
                                        layer.msg('删除成功', {
                                            time: 1500 //2秒关闭（如果不配置，默认是3秒）
                                        }, function () {
                                            table.reload('demo');
                                        });
                                    } else {
                                        layer.msg(res.message);
                                    }
                                }
                            })
                            layer.close(index); //关闭弹层
                        });

                        submit.trigger('click');
                    }
                    , btn2: function (index, layero) {
                        var iframeWindow = window['layui-layer-iframe' + index]
                        var submitID = 'LAY-user-front-submit'
                        var submit = layero.find('iframe').contents().find('#' + submitID);
                        //监听提交
                        iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
                            var field = data.field; //获取提交的字段
                            // 提交 Ajax 成功后，静态更新表格中的数据
                            $.ajax({
                                'url': "{:url('upload_ajax')}",
                                'method': 'POST',
                                'data': field,
                                'success': function (res) {
                                    if (res.code == 200) {
                                        layer.msg('编辑成功', {
                                            time: 1500 //2秒关闭（如果不配置，默认是3秒）
                                        }, function () {
                                            table.reload('demo');
                                        });
                                    } else {
                                        layer.msg(res.message);
                                    }
                                }
                            })
                            layer.close(index); //关闭弹层
                        });

                        submit.trigger('click');
                    }
                });
            });
        }

        layui.config({
            base: '/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'useradmin', 'table', 'layer', 'laydate'], function () {

            var $ = layui.$
                , form = layui.form
                , table = layui.table
                , layer = layui.layer
                , laydate = layui.laydate
            laydate.render({
                elem: '#time_time'
                , type: 'datetime'
                , range: '到'
                , format: 'yyyy-M-d H:m:s'
            });
            //表格
            var web_table = "{$table}";
            web_table = JSON.parse(web_table.replace(/&quot;/g, '"'));
            "{if $cs_url}"
            var str = "{$cs_url}";
            str = str.replace(/&amp;/, "&");
            var url = "{:url('datalist')}" + str;
            "{else}"
            var url = "{:url('datalist')}";
            "{/if}"
            url = url.replace(/&amp;/g, '&');
            console.log(url, 111)
            table.render({
                elem: '#demo'
                , limit: 50
                , url: url//数据接口
                , page: true //开启分页
                , cols: [web_table]
            });
            //监听搜索
            form.on('submit(LAY-user-front-search)', function (data) {
                var field = data.field;

                //执行重载
                table.reload('demo', {
                    where: field
                });
            });

            //事件
            var active = {
                batchdel: function () {
                    //批量删除按钮操作
                    var checkStatus = table.checkStatus('demo')
                        , checkData = checkStatus.data; //得到选中的数据

                    if (checkData.length === 0) {
                        return layer.msg('请选择数据');
                    }

                    var prompt = layer.prompt({
                        formType: 1
                        , title: '敏感操作，请验证口令'
                    }, function (value, index) {
                        if (value !== '123456') {
                            return layer.msg('口令错误');
                        }
                        layer.closeAll();
                        var id = '';
                        for (var i = 0; i < checkData.length; i++) {
                            id += checkData[i]['id'] + ','
                        }
                        layer.confirm('确定删除吗？', function (index) {

                            //执行 Ajax 后重载
                            $.ajax({
                                'url': "{:url('delete')}",
                                'method': 'POST',
                                'data': { id: id },
                                'success': function (res) {
                                    if (res.code == 200) {
                                        layer.msg('删除成功', {
                                            time: 1500 //2秒关闭（如果不配置，默认是3秒）
                                        }, function () {
                                            table.reload('demo');
                                        });
                                    } else {
                                        layer.msg(res.message);
                                    }
                                }
                            })
                        });
                    });
                }
                , add: function () {
                    //新增按钮操作
                    layer.open({
                        type: 2
                        , title: '添加'
                        , content: 'add.html'
                        , maxmin: true
                        , area: ["{$popup_size.width}", "{$popup_size.height}"]
                        , btn: ['确定', '取消']
                        , yes: function (index, layero) {
                            var iframeWindow = window['layui-layer-iframe' + index]
                            var submitID = 'LAY-user-front-submit'
                            var submit = layero.find('iframe').contents().find('#' + submitID);
                            //监听提交
                            iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
                                var field = data.field; //获取提交的字段
                                //提交 Ajax 成功后，静态更新表格中的数据
                                $.ajax({
                                    'url': "{:url('add_ajax')}",
                                    'method': 'POST',
                                    'data': field,
                                    'success': function (res) {
                                        if (res.code == 200) {
                                            layer.msg('添加成功', {
                                                time: 1500 //2秒关闭（如果不配置，默认是3秒）
                                            }, function () {
                                                table.reload('demo');
                                            });
                                        } else {
                                            layer.msg(res.message);
                                        }
                                    }
                                });
                                layer.close(index); //关闭弹层
                            });

                            submit.trigger('click');
                        }
                    });
                }
            };
            $('.layui-btn.layuiadmin-btn-useradmin').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
        });
        function data_url(table = null) {
            console.log(table)
            //优化
            $.ajax({
                url: "{:url('optimize')}",
                data: { tables: table },
                success: function (res) {
                    console.log(res);
                }
            })
        };

        //弹出查看图片
        function fdtop(img) {
            $("#mc").css({ display: 'flex' });
            $("#mc").find('img').attr('src', img);
        }
        //关闭弹出层
        $("#mc").click(function () {
            $("#mc").hide();
        })
    </script>
</body>

</html>